<?php
if($_POST['edit_news']!=true) echo '';
else {
 $news_name=trim(addslashes($_POST['news']));
 $news_descr=trim(addslashes($_POST['descr_news']));
 $news_content=trim(addslashes($_POST['myTextArea']));
 
 //Selecting the information from the news 
 $select_news_name='SELECT news_name FROM news WHERE news_name="'.$news_name.'" AND news_id!="'.$_GET['id'].'"';
 $r=mysql_query($select_news_name);
 
 if(mysql_num_rows($r)!=0){
	echo "<p class='error'>Името съществува!</p>";
 }
 else{
 if(empty($news_name)||empty($news_content)||empty($news_descr)){
   echo "<p class='error'>Моля, попълнете ВСИЧКИ полета!</p>";
 }
 else{
	   //Updating news
	   $sql='UPDATE news SET news_name="' . $news_name . '", content="' . $news_content . '", news_descr="'.$news_descr.'" WHERE news_id="' . $_GET['id'] . '"';
	   $re=mysql_query($sql);
	   echo "<center>Успешно обновяване!</center>";
	   echo '<meta http-equiv="refresh" content="0;url=../news/seenews.php?id=' .$_GET['id']. '">';
 }
 }
}
?>